package tj.eskhata.pos.web.output;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.PageParameters;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.extensions.markup.html.repeater.data.sort.OrderByBorder;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.StatelessForm;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.ReuseIfModelsEqualStrategy;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.spring.injection.annot.SpringBean;

import tj.eskhata.pos.*;
import tj.eskhata.pos.domain.Bank;
import tj.eskhata.pos.domain.Client;
import tj.eskhata.pos.domain.SprPaySystem;
import tj.eskhata.pos.services.PosService;
import tj.eskhata.pos.web.BasePage;


public class Output extends BasePage 
{
	
	private static class ClientNameForm extends Form {
		@SpringBean
		private PosService service;
		private Client client;
		private String strName="";
		private String strPasp;
		private TextField txtName;
		private TextField txtPasp;
		
		private String getStrName() {
			return this.strName;
		}
		private void setStrName(String strName) {
			this.strName=strName;
		}
		
		public ClientNameForm(final String id,String strn,String strp) {
			super(id);
			//setModel(new CompoundPropertyModel(this));
			
			txtName= new TextField("clName",new Model(strn));		
			add(txtName);
			txtPasp=new TextField("clPasp",new Model(strp));
			add(txtPasp);
			
			Button butNew=new Button("new"){			
				@Override
				public void onSubmit()
				{									
					//String value=(String)txtName.getModelObject();
					//PageParameters pars=new PageParameters();
					//pars.add("strname", value);
					setResponsePage(NewClient.class);
				}
			};
			butNew.setDefaultFormProcessing(false);
			add(butNew);					
			//add(ddcPaySys);
			Button butFind= new Button("find");
			add(butFind);
						
		}
		
		public void onSubmit()
		{									
			PageParameters pars=new PageParameters();
			String value=(String)txtName.getModelObject();
			pars.add("strname", value);
			pars.add("strpasp", (String)txtPasp.getModelObject());
			setResponsePage(FilterClient.class, pars);
		}
	}
	public Output(final PageParameters parameters) {
	
		String strn="";
		if (parameters.containsKey("strname")){
			strn=parameters.getString("strname");
		}
		String strp="";
		if (parameters.containsKey("strpasp")){
			strp=parameters.getString("strpasp");
		}
		
		ClientNameForm frmClient=new ClientNameForm("outputform",strn,strp);
		add(frmClient);
		
		//TABLE OF CLIENTS
		ClientListPanel clientLP= new ClientListPanel("clientlist",strn,strp);		
		clientLP.setOutputMarkupId(true);
		add(clientLP);
	}
}
